package com.luban.beanPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

@Component
public class TestBeanPostProcessor implements BeanPostProcessor , PriorityOrdered {
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if("indexDaoImpl".equals(beanName)){
			System.out.println("我在初始化之前插手了");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if("indexDaoImpl".equals(beanName)){
			System.out.println("我在初始化之后插手了");
		}
		return bean;
	}

	/**
	 * 后置处理器先后执行的顺序
	 * @return
	 */
	@Override
	public int getOrder() {
		return 0;
	}
}
